package com.sunny.blog.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* @Description:资源拦截器
* @ClassName: ResourceConfig
* @author sunt
* @date 2019年3月25日下午5:35:43
 */
@Configuration
public class ResourceConfig implements WebMvcConfigurer {
	
	@Autowired
	private BlogInterceptor blogInterceptor;

	/**
	 * 拦截器执行两次解决方案
	 * org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error
	 * 也是一个controller路径为/error
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		 registry.addInterceptor(blogInterceptor).addPathPatterns("/**")
		 //放行的请求
		 .excludePathPatterns("/user/genVerifyCode","/user/login");
	}
}
